import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './assets/css/index.scss'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import zhCn from 'element-plus/es/locale/lang/zh-cn'


function setRem() {
  const designWidth = 1920;
  const clientWidth = document.documentElement.clientWidth || document.body.clientWidth; // 获取屏幕宽度
  document.documentElement.style.fontSize = (clientWidth / designWidth) * 100 + 'px';
}

setRem();
window.onresize = setRem;

const app = createApp(App)

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title as string;
  }
  next();
});

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(ElementPlus, {
  locale: zhCn,
})
app.use(router).mount('#app')
